rm(list=ls())

library(ggplot2)
library(xlsx)
library(readxl)

setwd("")


################# TFA
all<-read_excel("pew_cps_turnout_cohort.xlsx")

attach(all) 

plot1<-ggplot(all, aes(y=turnout, reorder(age, num), group = group)) + 
  geom_point(data=all, size=10, colour="grey30") +
  geom_line(colour="grey30") +
  theme_bw() + theme(panel.grid.major = element_blank(), 
                     panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")) +
  labs(x="Age Group of Voters", y="Voter Turnout in Midterm Elections", title="") +
  annotate("text", x=6, y = 56, label = "Silent", size=13, fontface="bold", colour="blue", angle=0) +
  annotate("text", x=6, y = 49, label = "Boomer", size=13, fontface="bold", colour="blue", angle=0) +
  annotate("text", x=6, y = 40, label = "Gen X", size=13, fontface="bold", colour="blue", angle=0) +
  annotate("text", x=3, y = 27, label = "Millenial", size=13, fontface="bold", colour="blue", angle=0) +
  theme(text = element_text(size=45)) +  theme(legend.position="none") +
  scale_y_continuous(limits=c(0, 70)) 
plot1
ggsave(plot1, file="cohort_turnout_by_age_tfa.pdf", width=9, height=6, scale=2)





